#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5+5;
int n,x,a[N],ans1,ans2,las;
signed main()
{
	freopen("guard.in","r",stdin);
	freopen("guard.out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>x>>x;
	for(int i = 1;i<=n;i++)
		cin>>a[i];
	for(int i = 1;i<n;i++)
	{
		int mx = max({a[i],a[i+1],las});
		int add = max(a[i],mx-las);
		ans1+=add;
		las+=add-a[i+1];
	}
	reverse(a+1,a+n+1);
	las = 0;
	for(int i = 1;i<n;i++)
	{
		int mx = max({a[i],a[i+1],las});
		int add = max(a[i],mx-las);
		ans2+=add;
		las+=add-a[i+1];
	}
	cout<<max(ans1,ans2);
	return 0;
}

